package com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.service.business.dept.convert;

import com.yonyou.iuap.ipaas.connector.sdwcoatencent.api.model.business.dept.BipDept;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.SdwcoatencentConnection;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.service.core.ParamConvertService;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class DeptParamConvertService implements ParamConvertService<BipDept, BipDept> {
    @Override
    public List<BipDept> convertForBatchSave(List<BipDept> list, SdwcoatencentConnection connection) {
        return (List)list.stream().filter((item) -> {
            return !"global00".equals(item.getCode()) && item.getSyncFlag();
        }).collect(Collectors.toList());
    }

    @Override
    public List<BipDept> convertForBatchDelete(List<BipDept> list, SdwcoatencentConnection connection) {
        return (List)list.stream().sorted(Comparator.comparingInt(BipDept::getLevel).reversed()).collect(Collectors.toList());

    }

    @Override
    public BipDept convertForSave(BipDept objet, SdwcoatencentConnection connection) {
        return null;
    }

    @Override
    public BipDept convertForDelete(BipDept objet, SdwcoatencentConnection connection) {
        return null;
    }
}
